package com.example.demotest.pojo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;

@Table(name="table_userprofile")
@Entity

public class UserProfile {
    @Id
    private Integer userId; // 使用 user_id 作为主键 + 外键，保持一一对应

    @JsonIgnore
    @OneToOne
    @MapsId  // 关键！表示 userId 是从 User 中映射来的
    @JoinColumn(name = "user_id")  // 指定外键字段
    private User user;

    private String avatarUrl;
    private String email;
    private String gender;
    private String phone;
    private String address;

    @Override
    public String toString() {
        return "UserProfile{" +
                "userId=" + userId +
                ", user=" + user +
                ", avatarUrl='" + avatarUrl + '\'' +
                ", nickname='" + email + '\'' +
                ", gender='" + gender + '\'' +
                ", phone='" + phone + '\'' +
                ", address='" + address + '\'' +
                '}';
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
}
